package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.pojo.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface MenuMapper extends BaseMapper<Menu> {

    //根据角色id获取对应主菜单
    @Select(" select m.name title,m.id,m.icon,m.path " +
            " from t_role_menu rm , t_menu m " +
            " where rm.menu_id = m.id  and rm.role_id = #{roleId} and m.level = 1 " +
            " ORDER BY m.priority")
    List<Map> findParentMenuByRoleIds(@Param("roleId") Integer roleId);

    @Select("select name title,linkUrl,path " +
            "from t_menu " +
            "where parentMenuId = #{meunId} and level = 2")
    List<Map> findSonMenuByParentMenuId(@Param("meunId") String meunId);
}
